package com.example.datn.adapter;

import com.example.datn.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AlbumPhotoAdapter extends BaseAdapter {

	private Context context;
	private final String[] albumValues;

	public AlbumPhotoAdapter(Context context, String[] mobileValues) {
		this.context = context;
		this.albumValues = mobileValues;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View gridView;

		if (convertView == null) {

			gridView = new View(context);

			// get layout from mobile.xml
			gridView = inflater.inflate(R.layout.album_photo_item, null);

			// set value into textview
			TextView textView = (TextView) gridView
					.findViewById(R.id.grid_item_label);
			textView.setText(albumValues[position]);

			// set image based on selected text
			ImageView imageView = (ImageView) gridView
					.findViewById(R.id.grid_item_image);

			String mobile = albumValues[position];

			if (mobile.equals("Quang Lê với Phương Mỹ Chi")) {
				imageView.setImageResource(R.drawable.quanglephuongmychi);
			} else if (mobile.equals("Quang Lê song ca cùng mỹ nhân")) {
				imageView.setImageResource(R.drawable.quanglemynhan);
			} else if (mobile.equals("CD không phải tại chúng mình")) {
				imageView.setImageResource(R.drawable.khongphaitaichungminh);

			} else if (mobile.equals("Quang lê xuân trên quê hương")) {
				imageView.setImageResource(R.drawable.xuantrenquehuong);
			} else if (mobile.equals("Quang Lê hát trên quê hương")) {
				imageView.setImageResource(R.drawable.hattrenquehuong);
			}
		} else {
			gridView = (View) convertView;
		}

		return gridView;

	}

	public int getCount() {
		return albumValues.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

}
